import request from "../utils/request";

export function getBooks(page = 1, pageSize = 20, type = null, name = '', state = [0, 1]) {
  return request.get('/books', {
    params: {page, pageSize, type, name, state: state.join(',')}
  })
}

export function getBook(id) {
  return request.get('/books/' + id);
}

export function addBook(book) {
  return request.post('/books', book);
}

export function updateBook(book) {
  return request.patch('/books', book);
}

export function deleteBook(id) {
  return request.delete('/books', {
    params: {id}
  })
}
